package com.automannn.dubbo.extensionLoader;

import org.apache.dubbo.cache.CacheFactory;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.extension.SPI;
import org.apache.dubbo.rpc.Protocol;

import java.util.ArrayList;
import java.util.Set;

/**
 * @author automannn
 * @Date 2022/4/18
 */
public class ExtenSionLoaderTest {

    public static void main(String[] args) {
        ExtensionLoader loader = ExtensionLoader.getExtensionLoader(Protocol.class);
        Set<String> supportedExtensions = loader.getSupportedExtensions();
        ArrayList<String> extensionList = new ArrayList<>();

        //获取所有的扩展点实现
        for (String supportedExtension : supportedExtensions) {
            extensionList.add(supportedExtension);
        }
        System.out.println(extensionList.size());
        System.out.println(extensionList);

        //获取指定名称的实现类
        System.out.println(loader.getExtension("http"));

        //获取自适应实现类
        System.out.println(loader.getAdaptiveExtension());

    }
}
